@extends('admin.layouts.main')
@section('header')
    @parent
@endsection
@section('content')
    <form class="layui-form">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">父级</label>
                <div class="layui-input-inline">
                    <select name="parent_id" id="parentId">
                        <option value="0">顶级父类</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">标签名</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="search" name="name" placeholder="请输入标签" />
                </div>
            </div>

        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-inline">
                    <input type="radio" name="status" value="1" checked title="正常">
                    <input type="radio" name="status" value="0"  title="禁用">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="hidden" name="id" value=""/>
                <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="submit">立即提交</button>
            </div>
        </div>
    </form>
@endsection
@section('footer')
    @parent
    <script type="text/javascript">
       layui.use(['layer','jquery','form'],function () {
           var layer = layui.layer,
               $ = layui.jquery,
               form = layui.form;
           form.on("submit(submit)",function (data) {
               var formData = data.field;
               //console.log(formData);
                goConfirm('{{ url('admin/tag/edit') }}',formData,'确认提交数据',1);
               return false;
           });
           getDetail();
           function getDetail(){
               var id = getUrlParam('id');
               $('input[name="id"]').val(id);
               $.get('{{ url('admin/tag/detail') }}',{id:id},function (res) {
                   if(res.status == 200){
                       var data = res.data;
                       $('input[name="name"]').val(data.name);
                       $('input[name="status"][value="'+data.status+'"]').attr('checked',true);
                       buildOptions('{{ url('admin/tag/selectList') }}',{},'#parentId','id','name',parentId,data.parent_id);
                   }
               },'json');
           }
       });

    </script>
@endsection